
  <div class='row'>
    <div class='span6'>
      <div class='panel'>
        <h3><?php echo sprintf(lang('rankings_for_stage'), $stage->stage_id);?></h3>
        <table class='table table-condensed'>
          <thead>
            <tr>
              <th>Pos</th>
              <th><?php echo lang('user_team');?> </th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('stage_results');?>"><img src="<?php echo base_url();?>assets/images/jersey_stage.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('overall_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_yellow.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('points_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_green.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('mountain_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_mountain.gif" /></a></th>
              <th class='centertext'><?php echo lang('total');?></th>
            </tr>
          </thead>
          <tbody>
      <?php
      $r = 0;
      $real_count = 0;
      $old = 0;
      foreach($stage_ranking as $rank)
      {
        $real_count++;
        if($rank->points_total != $old)
        {
          $r = $real_count;
        }
        else
        {
           
        }
      ?>
            <tr>
              <td class='centertext'><?php echo $r;?></td>
              <td><?php echo anchor('info/user_teams/'.$rank->id, $rank->username);?></td>
              <td class='centertext'><?php echo $rank->points_stage;?></td>
              <td class='centertext'><?php echo $rank->points_yellow;?></td>
              <td class='centertext'><?php echo $rank->points_green;?></td>
              <td class='centertext'><?php echo $rank->points_mountain;?></td>
              <td class='centertext'><?php echo $rank->points_total;?></td>
            </tr>
      <?php
        $old = $rank->points_total;
      }
      ?> 
          </tbody>
        </table>

      </div>
    </div>
    <div class='span6'>
      <div class='panel'>
        <h2><?php echo lang('stage')." ".$stage->stage_id; ?></h2>
        <h3><?php echo $stage->stage_depart." - ".$stage->stage_arrive." (".lang($stage->stage_type)." ".$stage->stage_distance.")"; ?></h3>

          <table class='table table-condensed'>
            <thead>
              <tr>
                <th colspan='5' class='centertext'><?php echo lang('stage_results');?></th>
              </tr>
            </thead>
            <tbody>  
            <?php foreach($stage_result as $key => $rider)
            { 
              if(is_object($rider))
              { ?>
              <tr>
                <td><?php echo ($key+1).".";?></td>
                <td><?php echo $rider->number;?></td>
                <td><?php echo anchor('info/rider/'.$rider->rider_id,$rider->last_name." ".$rider->first_name);?></td>
                <td><?php echo $rider->team_name;?></td>
              </tr>
            <?php 
              }
            }
            ?>
            </tbody>
          </table>
        </div>

        <div class="panel yellow-panel">
          <table class='table table-condensed'>
            <thead>
              <tr>
                <th colspan='5' class='centertext'><?php echo lang('overall_standing');?></th>
              </tr>
            </thead>
            <tbody>  
            <?php foreach($stage_yellow as $key => $rider)
            { 
              if(is_object($rider))
              { ?>
              <tr>
                <td><?php echo ($key+1).".";?></td>
                <td><?php echo $rider->number;?></td>
                <td><?php echo anchor('info/rider/'.$rider->rider_id,$rider->last_name." ".$rider->first_name);?></td>
                <td><?php echo $rider->team_name;?></td>
              </tr>
            <?php 
              }
            }
            ?>
            </tbody>
          </table>
        </div>

        <div class='panel green-panel'>
          <table class='table table-condensed'>
            <thead>
              <tr>
                <th colspan='5' class='centertext'><?php echo lang('points_standing');?></th>
              </tr>
            </thead>
            <tbody>  
            <?php foreach($stage_green as $key => $rider)
            { 
              if(is_object($rider))
              { ?>
              <tr>
                <td><?php echo ($key+1).".";?></td>
                <td><?php echo $rider->number;?></td>
                <td><?php echo anchor('info/rider/'.$rider->rider_id,$rider->last_name." ".$rider->first_name);?></td>
                <td><?php echo $rider->team_name;?></td>
              </tr>
            <?php 
              }
            }
            ?>
            </tbody>
          </table>
        </div>

        <div class='panel mountain-panel'>
          <table class='table table-condensed'>
            <thead>
              <tr>
                <th colspan='5' class='centertext'><?php echo lang('mountain_standing');?></th>
              </tr>
            </thead>
            <tbody>  
            <?php foreach($stage_mountain as $key => $rider)
            { 
              if(is_object($rider))
              { ?>
              <tr>
                <td><?php echo ($key+1).".";?></td>
                <td><?php echo $rider->number;?></td>
                <td><?php echo anchor('info/rider/'.$rider->rider_id,$rider->last_name." ".$rider->first_name);?></td>
                <td><?php echo $rider->team_name;?></td>
              </tr>
            <?php 
              }
            }
            ?>
            </tbody>
          </table>
        </div>      
      </div>
    </div>
  </div>
